import { RELATIONSHIP_SUPPLIERS_SELECT_LIST } from '@/pages/supplier/constants/common'
import { list2Obj } from '@/pages/supplier/utils';
const ACCEPT_INVOICE_OPTIONS = [
  { label: '是', value: 1 },
  { label: '否', value: 2 }
]
// 开票供应商列表
const FORM_ITEM_LIST = [
  {
    prop: 'supplierSearch',
    label: '供应商名称/代码',
    type: 'input'
  },
  {
    prop: 'invoiceSupplierSearch',
    label: '开票供应商代码',
    type: 'input'
  },
  {
    prop: 'payee',
    label: '收款人',
    type: 'input',
  },
  {
    prop: 'bankAccount',
    label: '收款账号',
    type: 'input',
  },
  {
    prop: 'bankName',
    label: '开户行',
    type: 'input',
  },
  {
    prop: 'bankNumber',
    label: '联行号',
    type: 'input',
  },
  {
    prop: 'acceptInvoice',
    label: '是否承税',
    type: 'select',
    clearable: true,
    options: ACCEPT_INVOICE_OPTIONS,
  },
  {
    prop: 'relation',
    label: '与供应商关系',
    type: 'select',
    clearable: true,
    options: RELATIONSHIP_SUPPLIERS_SELECT_LIST,
  },
  {
    prop: 'businessContactName',
    label: '业务对接人',
    type: 'input',
  },
]
const getTableColumns = (parent) => {
  return [
    {
      title: '序号',
      key: 'index',
      width: 50
    },
    {
      title: '供应商代码',
      key: 'supplierCode'
    },
    {
      title: '供应商名称',
      key: 'supplierName',
    },
    {
      title: '开票供应商代码',
      key: 'invoiceSupplierCode'
    },
    {
      title: '开票供应商名称',
      key: 'invoiceSupplierName',
    },
    {
      title: '收款人',
      key: 'payee'
    },
    {
      title: '收款账号',
      key: 'bankAccount'
    },
    {
      title: '开户行',
      key: 'bankName'
    },
    {
      title: '联行号',
      key: 'bankNumber'
    },
    {
      title: '是否承兑',
      key: 'acceptInvoice',
      formatter: (row, columns, cellValue) => {
        return list2Obj(ACCEPT_INVOICE_OPTIONS)[cellValue]
      }
    },
    {
      title: '与供应商关系',
      key: 'relation',
      formatter: (row, columns, cellValue) => {
        return list2Obj(RELATIONSHIP_SUPPLIERS_SELECT_LIST)[cellValue]
      }
    },
    {
      title: '关系证明',
      key: 'relationAnnex',
      render: (h, { row }) => {
        return <a onClick={() => { parent.downLoadFile(row) }}>{row.relationAnnex}</a>
      }
    },
    {
      title: '业务对接人',
      key: 'businessContactName'
    },
    {
      title: '不一致原因',
      key: 'differentReason'
    },
    {
      title: '不一致原因说明',
      key: 'differentRemark'
    },
  ]
}
export {
  FORM_ITEM_LIST,
  getTableColumns
}
